package com.dhecp.core.utils;
import com.alibaba.excel.metadata.Head;
import com.alibaba.excel.write.merge.AbstractMergeStrategy;
import org.apache.poi.ss.usermodel.Cell;
import org.apache.poi.ss.usermodel.Sheet;
import org.apache.poi.ss.util.CellRangeAddress;
import java.util.List;

public class ScreenValueMergeStrategy extends AbstractMergeStrategy {

    /**
     *  第几个表格
     */
    private Integer exportNum;

    public ScreenValueMergeStrategy() {
    }

    /**
     * @param exportNum      第几个表格
     */
    public ScreenValueMergeStrategy(Integer exportNum) {
        this.exportNum = exportNum;
    }

    @Override
    protected void merge(Sheet sheet, Cell cell, Head head, Integer relativeRowIndex) {
        if (relativeRowIndex != null){
            if (cell.getColumnIndex() == 1){
                if (relativeRowIndex %2 != 0){
                    CellRangeAddress cellRangeAddress1 = new CellRangeAddress(21+relativeRowIndex,21+relativeRowIndex,1,7);
                    sheet.addMergedRegionUnsafe(cellRangeAddress1);
                }

            }
        }
    }
}
